<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <div class="section">
                <h1>Caixa de Entrada</h1>
                <h:form>
                <div class="container_24">
                <p:dataTable id="inboxDataTable" var="inbox" value="#{managerInbox.messages()}" 
                             styleClass="grid_24"
                             rowIndexVar="rowid"
                             emptyMessage="Nenhum registro">  
                    <f:facet name="header">
                        Mensagens
                    </f:facet>
                    <p:column headerText="Corretor" width="200">  
                        <h:outputText value="#{inbox.userFrom.name}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                    </p:column>  
                    <p:column headerText="Assunto" width="450">  
                        <h:outputText value="#{inbox.subject}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                    </p:column>
                    <p:column headerText="Data">  
                        <h:outputText value="#{inbox.dateMessage}" styleClass="#{inbox.wasRead ? '' : 'unRead'}">
                            <f:convertDateTime pattern="dd/MM/yyyy - HH:mm" />
                        </h:outputText>
                    </p:column>  
                    <p:column headerText="Abrir" width="75" style="text-align: center">
                        <p:commandButton  update="@form" title="Visualisar Menssagem"
                                       actionListener="#{managerInbox.readMessage(inbox)}"
                                       icon="ui-icon-mail-open" />
                      </p:column>
                </p:dataTable> 
                </div>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>
</html>
